package com.topica.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.topica.R;
import com.topica.object.CourseUpdate;

public class AdapterCourseUpdate extends ArrayAdapter<CourseUpdate> {
	private LayoutInflater inflater;

	public AdapterCourseUpdate(Context context, int resource,
			int textViewResourceId, ArrayList<CourseUpdate> objects) {
		super(context, resource, textViewResourceId, objects);
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CourseUpdate update = getItem(position);
		ViewHolder holder;
		if (null == convertView) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.layout_item_update, null);
			holder.fullName = (TextView) convertView
					.findViewById(R.id.idUpdate);
			holder.status = (TextView) convertView
					.findViewById(R.id.fullNameUpdate);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.fullName.setText(update.getFullname());
		holder.status.setText(update.getStatus());
		
		return convertView;
	}

	private class ViewHolder {
		private TextView fullName;
		private TextView status;
	}
}
